/*
 * Copyright：fxsen <br/>
 * Date: 2021/9/19 12:32 <br/>
 * Author: <a href="mailto:fxsen@foxmail.com">fxsen</a>
 */
package com.fxsen.commons.sysmanager.core.service.impl;

import com.fxsen.commons.core.base.common.service.impl.CommonServiceImpl;
import com.fxsen.commons.sysmanager.core.entity.User;
import com.fxsen.commons.sysmanager.core.mapper.UserMapper;
import com.fxsen.commons.sysmanager.core.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

;

/**
 * @describe: 系统用户服务实现层 <br/>
 * @date: 2021/9/19 12:32 <br/>
 * @author: <a href="mailto:fxsen@foxmail.com">fxsen</a>
 */
@Service
public class UserServiceImpl extends CommonServiceImpl<UserMapper,User> implements IUserService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private IUserRoleService userRoleService;
    @Autowired
    private IMenuRoleService menuRoleService;
    @Autowired
    private IMenuService menuService;
    @Autowired
    private IRolePermissionService rolePermissionService;
    @Autowired
    private IPermissionService permissionService;
    @Override
    public List<User> getAll() {
        return userMapper.getAll();
    }
    @Override
    public User getByLoginName(String loginName) {
        return userMapper.getByLoginName(loginName);
    }

    /*@Override
    public Result<SsoUser> login(String loginName, String password) throws Exception {
        User user = this.getByLoginName(loginName);
        if (null == user){
            return Result.createError("用户名或密码错误！");
        }
        if (loginName.equals(user.getLoginName())){
            if (MD5Utils.validPasswd(password,user.getPassword())){
                SsoUser ssoUser = new SsoUser(user.getId(), user.getDeptId(), user.getLoginName(), user.getUserName(),
                        user.getType(), user.getEmail(), user.getPhone(), user.getSex(), user.getAvatar(), user.getStatus());
              *//*  ssoUser.setPermission(permissionService.findPermissionTagByUserId(user.getId()));*//*
                return Result.createSuccess(ssoUser);
            }else {return Result.createError("用户名或密码错误！");}
        }else {
            return Result.createError("用户名或密码错误！");
        }
    }
*/
    /*public static void main(String[] args) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        System.out.println(MD5Utils.getEncryptedPwd("xiaonaadmin"));
    }*/
}
